from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Edge()
# 有对话框的网址
url = ""

driver.get(url)

driver.maximize_window()
time.sleep(2)

# 切换到警告框
alert = driver.switch_to.alert
# 同意警告框
alert .accept()
# 取消警告框
alert.dismiss()
# 警告框中填写内容
alert.send_keys("")
# 警告框的文本内容
alert.text